package org.easy.db;

import lombok.Data;

/**
 * @Description: SQL解析器
 * @Author: wxl
 * @CreateTime: 2022/12/16 9:34
 */
@Data
public class SqlParse implements SqlParserInterface {

    private String sql;

    private Object[] args;

    public SqlParse (String sql) {
        this.sql = sql;
        this.validateSql();
    }

    private void validateSql() {

        if (this.sql.startsWith(OperatorType.insert.name())) {
            parseInsertSql();
        } else if (this.sql.startsWith(OperatorType.update.name())) {
            parseUpdateSql();
        } else if (this.sql.startsWith(OperatorType.select.name())) {
            parseSelectSql();
        } else if (this.sql.startsWith(OperatorType.delete.name())) {
            parseDeleteSql();
        }
    }

    /**
     * 解析插入语句SQL
     */
    @Override
    public void parseInsertSql() {

    }

    /**
     * 解析查询语句SQL
     */
    @Override
    public void parseSelectSql() {
        // select * from grc_iot_device_register where device_type = SENSOR and device_name = 传感器
        if (this.sql.contains("where")) {

        } else {
            this.args = new Object[]{};
        }
    }

    /**
     * 解析更新语句SQL
     */
    @Override
    public void parseUpdateSql() {

    }

    /**
     * 解析删除语句SQL
     */
    @Override
    public void parseDeleteSql() {

    }
}
